package com.nettylern.bio;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author liliang
 * @date 2019/12/4.
 */
public class TimeServer {

    public static void main(String[] args) throws IOException {
        int port = 8080;
        ServerSocket server = null;
        try {
            server = new ServerSocket(port);
            Socket socket = null;
            TimeServerHandlerExecutePool singleExecutor = new TimeServerHandlerExecutePool(50, 10000);
            System.out.println("服务器等待连接:");
            while (true) {
                socket = server.accept();
                // 伪异步 IO
                singleExecutor.execute(new TimeServerHandler(socket));
                // bio
//                new Thread(new TimeServerHandler(socket)).start();
            }
        } finally {
            if (server != null) {
                server.close();
            }
        }

    }
}
